//===============================================================================
// Microsoft patterns & practices Enterprise Library Contribution
// Exception Handling Application Block
//===============================================================================

using System;
using Microsoft.Practices.EnterpriseLibrary.Configuration.Design;
using Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.Design;
using EntLibContrib.ExceptionHandling.Configuration.Design.Properties;

namespace EntLibContrib.ExceptionHandling.Configuration.Design
{
	/// <summary>
	/// Command registrar for exception handling
	/// </summary>
	sealed partial class ExceptionHandlingCommandRegistrar : CommandRegistrar
	{
		#region Construction
		/// <summary>
		/// Initializes a new instance of the <see cref="ExceptionHandlingCommandRegistrar"/> class.
		/// </summary>
		/// <param name="serviceProvider">The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.</param>
		public ExceptionHandlingCommandRegistrar(IServiceProvider serviceProvider)
			: base(serviceProvider)
		{
		}
		#endregion

		#region Public Methods
		/// <summary>
		/// Register the commands.
		/// </summary>
		public override void Register()
		{
			AddSqlExceptionWrapHandlerNodeCommand();
			AddDefaultCommands(typeof(SqlExceptionWrapHandlerNode));

			AddErrorCodeEntryNodeCommand();
			AddDefaultCommands(typeof(ErrorCodeEntryNode));
		}
		#endregion

		#region Private Methods
		private void AddErrorCodeEntryNodeCommand()
		{
			AddMultipleChildNodeCommand(
				Resources.ErrorCodeEntryNodeUICommandText,
				Resources.ErrorCodeEntryNodeUICommandLongText,
				typeof(ErrorCodeEntryNode),
				typeof(SqlExceptionWrapHandlerNode));
		}

		private void AddSqlExceptionWrapHandlerNodeCommand()
		{
			AddMultipleChildNodeCommand(
				Resources.SqlExceptionWrapHandlerNodeUICommandText,
				Resources.SqlExceptionWrapHandlerNodeUICommandLongText,
				typeof(SqlExceptionWrapHandlerNode),
				typeof(ExceptionTypeNode));
		}
		#endregion
	}
}
